import { reactive } from "vue";
import { getListApi } from "@/api/configCenter/outBoundAgent";
import { getAllCompanyApi } from "@/api/managementCenter/departmentPersonnel";

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "出仓单号",
    keyName: "outWarehouseNumList"
  },
  {
    type: "input",
    label: "运单号",
    keyName: "waybillNumList"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "代理名称",
    keyName: "outWarehouseIdList",
    optionsRequest: getListApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  "1": [
    {
      field: "checkbox",
      type: "checkbox",
      minWidth: "50"
    },
    {
      field: "outWarehouseNum",
      title: "出仓单号",
      minWidth: "120"
    },
    {
      field: "brokerName",
      title: "代理名称",
      minWidth: "160"
    },
    {
      field: "createTime",
      title: "出仓单创建时间",
      minWidth: "160",
      formatter: "formatDate"
    },
    {
      field: "shipmentItem",
      title: "运单数",
      minWidth: "20"
    },
    {
      field: "shipmentBoxItem",
      title: "件数",
      minWidth: "20"
    },
    {
      field: "shipmentSquaresNumber",
      title: "方数",
      minWidth: "20"
    },
    {
      field: "shipmentSettlementWeight",
      title: "结算重",
      minWidth: "20"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "90",
      renderSlot: "action",
      fixed: "right"
    }
  ],
  "2": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "20",
      fixed: "left"
    },
    {
      field: "outWarehouseNum",
      title: "出仓单号",
      minWidth: "120"
    },
    {
      field: "brokerName",
      title: "代理名称",
      minWidth: "160"
    },
    {
      field: "createTime",
      title: "出仓单创建时间",
      minWidth: "160",
      formatter: "formatDate"
    },
    {
      field: "shipmentItem",
      title: "运单数",
      minWidth: "20"
    },
    {
      field: "shipmentBoxItem",
      title: "件数",
      minWidth: "20"
    },
    {
      field: "shipmentSquaresNumber",
      title: "方数",
      minWidth: "20"
    },
    {
      field: "shipmentSettlementWeight",
      title: "结算重",
      minWidth: "20"
    },
    {
      field: "userDriverName",
      title: "司机",
      minWidth: "20"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "120",
      renderSlot: "action",
      fixed: "right"
    }
  ],
  "3": [
    {
      field: "outWarehouseNum",
      title: "出仓单号",
      minWidth: "20"
    },
    {
      field: "brokerName",
      title: "代理名称",
      minWidth: "30"
    },
    {
      field: "createTime",
      title: "出仓单创建时间",
      minWidth: "50",
      formatter: "formatDate"
    },
    {
      field: "shipmentItem",
      title: "运单数",
      minWidth: "20"
    },
    {
      field: "shipmentBoxItem",
      title: "件数",
      minWidth: "20"
    },
    {
      field: "shipmentSquaresNumber",
      title: "方数",
      minWidth: "20"
    },
    {
      field: "shipmentSettlementWeight",
      title: "结算重",
      minWidth: "20"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "50",
      renderSlot: "action",
      fixed: "right"
    }
  ]
};
